package com.xhx.dubbo.consumer.service;

import com.weimob.learn.springbootdubbo.dubbo.HelloDubboService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @program: xh-learn-record
 * @description:
 * @author: sch
 * @create: 2023-03-05 16:10
 **/
@Component
public class HelloService implements CommandLineRunner {
    @DubboReference
    private HelloDubboService helloDubboService;


    @Override
    public void run(String... args) throws Exception {
        new Thread(() -> {
            System.out.println("消费者启动并开始调用...");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(helloDubboService.sayHello("I'm consumer"));
        }).start();
    }
}
